# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
import json

class QsbkPipeline(object):
    def __init__(self):
        self.fq=open('duanzi.json','w',encoding='utf-8')

    def open_spider(self,spider):
        print('这是爬虫开始了',self.fq)

    #yield传过来之后就是item这个参数了
    def process_item(self, item, spider):
        item=json.dumps(item,ensure_ascii=False)
        print('*'*30)
        self.fq.write(item+'\n')

    def close_spider(self,spider):
        print('这是爬虫关闭了')
        self.fq.close()
